package rest.common;

import java.io.File;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import model.MenuItem;

import org.codehaus.jackson.map.ObjectMapper;

import utils.ResourceUtils;

@Path("/leftmenu")
public class LeftMenuResource {

	@SuppressWarnings("unchecked")
	@GET
	@Produces({ MediaType.APPLICATION_JSON })
	public List<MenuItem> leftMenu() throws Exception {
		String menuJson = ResourceUtils.getWebapp(this) + "/json/menu.json";
		ObjectMapper mapper = new ObjectMapper();
		List<MenuItem> menus = mapper.readValue(new File(menuJson), List.class);
		return menus;
	}
}
